﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Devsoft.Utilities.Extentions
{
    public static class DateTimeExtensions
    {
        // returns the number of milliseconds since Jan 1, 1970 (useful for converting C# dates to JS dates)
        public static long ToUnixTicks(this DateTime dt)
        {
            DateTime d1 = new DateTime(1970, 1, 1);
            DateTime d2 = dt.ToUniversalTime();
            TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
            return Convert.ToInt64(ts.TotalMilliseconds);
        }
    }
}
